package heima3_2.cn.osc.hold;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import net.oschina.app.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import heima3_2.cn.osc.base.BaseHolder;
import heima3_2.cn.osc.base.MyBaseAdapter;
import heima3_2.cn.osc.model.bean.GeneralNewsBean;
import heima3_2.cn.osc.ui.activity.ComprehensiveActivity;

public class SyntheHotsHold extends BaseHolder<GeneralNewsBean.NewsBean> {


    @Bind(R.id.tv_title)
    TextView mTvTitle;
    @Bind(R.id.tv_body)
    TextView mTvBody;
    @Bind(R.id.tv_author)
    TextView mTvAuthor;
    @Bind(R.id.tv_pubdate)
    TextView mTvPubdate;
    @Bind(R.id.tv_commentcount)
    TextView mTvCommentcount;
    private GeneralNewsBean.NewsBean mBean;

    public SyntheHotsHold(Context context, ViewGroup parent, MyBaseAdapter<GeneralNewsBean.NewsBean> adapter, int position, GeneralNewsBean.NewsBean bean) {
        super(context, parent, adapter, position, bean);

    }

    @Override
    public View onCreateView(final Context context, ViewGroup parent, int position, GeneralNewsBean.NewsBean bean) {
        this.mBean=bean;
        View view = LayoutInflater.from(context).inflate(R.layout.lv_synthe_item, parent, false);
        ButterKnife.bind(this, view);
        final int ADVISORY_DETAILS=2;

        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent =new Intent(context, ComprehensiveActivity.class);
                intent.putExtra("ADVISORY_HOST",ADVISORY_DETAILS);
                Bundle bundle=new Bundle();
                bundle.putSerializable("HOST",mBean);
                intent.putExtras(bundle);
                context.startActivity(intent);
            }
        });
        return view;
    }

    @Override
    protected void onRefreshView(GeneralNewsBean.NewsBean bean, int position) {
        mTvTitle.setText(bean.getTitle());
        mTvBody.setText(bean.getBody());
        mTvAuthor.setText(bean.getAuthor());
        mTvPubdate.setText(bean.getPubDate());
        mTvCommentcount.setText(bean.getCommentCount()+"");
    }
}